<html>
<head><meta charset="utf-8"><title>rustc asm closure [Solved] · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustc.20asm.20closure.20.5BSolved.5D.html">rustc asm closure [Solved]</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239967940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustc%20asm%20closure%20%5BSolved%5D/near/239967940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tomáš Pecl <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustc.20asm.20closure.20.5BSolved.5D.html#239967940">(May 23 2021 at 18:03)</a>:</h4>
<p>Hello, I have been experimenting with closures in rust playground and I have been looking at the generated assembly code. I was very surprised when I found that creating two different closures would generate two separate blocks of code which surprisingly had the same name/label. How is that possible? I would think that each closure should have a different label when they have different code.</p>
<p>this is how the labels in the assembly look like:</p>
<p>playground::main::{{closure}}:<br>
some assembly code for closure1...</p>
<p>playground::main::{{closure}}:<br>
some assembly code for closure2...</p>
<p>link to the playground:<br>
<a href="https://play.rust-lang.org/?version=stable&amp;mode=release&amp;edition=2018&amp;gist=d179c85988cb478c087936780d31d02a">https://play.rust-lang.org/?version=stable&amp;mode=release&amp;edition=2018&amp;gist=d179c85988cb478c087936780d31d02a</a></p>



<a name="239969446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/rustc%20asm%20closure%20%5BSolved%5D/near/239969446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tomáš Pecl <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/rustc.20asm.20closure.20.5BSolved.5D.html#239969446">(May 23 2021 at 18:29)</a>:</h4>
<p>Well I just forgot to disable symbol demangling. I should have noticed that earlier.</p>
<p>the actual labels are:</p>
<p>_ZN10playground4main28_$u7b$$u7b$closure$u7d$$u7d$17hebe4c68ea3bcccc0E:<br>
some assembly code for closure1...</p>
<p>_ZN10playground4main28_$u7b$$u7b$closure$u7d$$u7d$17h718c5dce116d2739E:<br>
some assembly code for closure2...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>